<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>VUE第一天 v-for</title>
</head>
<body>
  <div id="app"> 
    <p>1.v-for循环数组</p>
    <ul>
      <li v-for="(hobby,index) in hobbyList">{{index + 1}}.{{hobby}}</li> 
    </ul>
    <hr>
    <p>2.v-for循环对象</p>
    <div v-for="(val,key,index) in people" :key="index">{{index + 1}}.{{key}}:{{val}}</div>
    <hr>
    <p>2.v-for循环整数</p>
    <span v-for="num in 5">{{num}}</span><br>
    <!-- v-on:事件监听 -->
    <button v-on:click="showNum(num)" @contextMenu="showNum1(num)" v-for="num in 5">{{num}}</button>
    <hr>
    <!-- v-bind:绑定标签属性 -->
    <input :type="typeA" v-bind:value="people.age" >
    <img :src="path">
    <hr>
    <!-- v-model:绑定表单控件：v-on+v-bind -->
    <hr>
    <div v-for="num in arr1">
      <span v-for="item in num">{{item}}</span>
    </div>
  </div>
  <script src="../vue.js"></script>
  <script>
    let vm = new Vue({
      el: '#app',
      data: {
        hobbyList: ['唱','跳','rap','打篮球'],
        arr1: [
          [1,3,5,7,9],
          [2,4,6,8,10]
        ],
        people: {
          name: 'Jack',
          age: 18,
          job: 'student',
          sex: '男'
        },
        typeA: 'button',
        path: '../logo.png'
      },
      methods: {
        showNum(num) {
          console.log(num);
        },
        showNum1(num) {
          console.log('右键',num);
        }
      },
    });
  </script>
</body>
</html>